package com.lin.service;

import com.lin.dao.IUserDao;
import com.lin.dao.UserDaoImpl;
import com.lin.utils.MailUtils;
import com.lin.utils.UUIDUtils;
import com.lin.vo.User;

public class UserServiceImpl implements IUserService {
	private IUserDao userDao=new UserDaoImpl();
	@Override
	public void regist(User user) {
		// 设置用户id
		user.setUid(UUIDUtils.getUUID());
		// 设置用户状态码(0:表示没有激活      1:表示已经激活)
		user.setState(0); 
		// 设置用户激活码
		String code = new StringBuffer(UUIDUtils.getUUID()).append(UUIDUtils.getUUID()).toString();
		user.setCode(code);
		userDao.save(user);
		// 发送一封激活文件
		MailUtils.sendMail(user.getEmail(), code);
	}
	@Override
	public User findByCodeUser(String code) {
		return userDao.findByCodeUser(code);
	}
	@Override
	public void update(User user) {
		userDao.update(user);
		
	}
	@Override
	public boolean validateAjaxUserName(String userName) {
		
		return userDao.validateAjaxUserName(userName);
	}
	@Override
	public User login(User user) {
	
		return userDao.login(user);
	}




}
